/**
 *
 * 版权所有 © cybersky.com
 *
 */
package cn.cybertron.primus.report.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.nutz.ioc.annotation.InjectName;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Fail;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

import cn.cybertron.nutz.ext.i18n.Bundle;
import cn.cybertron.nutz.ext.mvc.Pager;
import cn.cybertron.nutz.ext.mvc.adaptor.ExtendPairAdaptor;
import cn.cybertron.primus.logging.annotation.Log;
import cn.cybertron.primus.report.entity.ReportCache;
import cn.cybertron.primus.security.annotation.AccessRestrict;

/**
 * 中间表管理
 * 	查看中间表
 * 	用户自定义中间表
 * @author ch
 *
 */
@IocBean
@InjectName("reportCacheController")
@At("/report/cache")
@AccessRestrict(permissions = "report")
public class ReportCacheController {

	protected Bundle bundle = new Bundle("report");

	/**
	 * 进入中间表页面
	 * @param request
	 * @param session
	 */
	@At("/")
	@Ok("jsp:pages.report.cache")
	@Log(record = false)
	public void index(HttpServletRequest request, HttpSession session) {
		
	}
	
	/**
	 * 获取中间表数据源
	 * @param type
	 * @param id
	 * @param stepNum
	 * @param request
	 */
	@At("/getDataSource")
	@Ok("json")
	@Log(key = "report.log.get.datasource", bundle = "report")
	public String getDataSource(@Param("uuid") String uuid, HttpServletRequest request) {
		StringBuffer filterfield = new StringBuffer();
				
		return filterfield.toString();
	}
	
	/**
	 * 添加自定义报表
	 * @param request
	 * @param session
	 */
	@At("/savereport")
	@Ok("json")
	@Fail("json")
	@Log(key = "report.log.save.reportcache", bundle = "report")
	@AdaptBy(type= ExtendPairAdaptor.class)
	public void saveReport(@Param("::cache.") ReportCache cache, HttpServletRequest request) 
	{
		
	}

	/**
	 * 根据条件模糊查找报表
	 * @param fuzzy
	 * @return
	 */
	@At("/listreportcache")
	@Ok("json")
	@Fail("json")
	@Log(key = "report.log.list.reportcache", bundle = "report")
	public Pager<ReportCache> listReport(HttpSession session, @Param("fuzzy") String fuzzy , @Param("::pager.")Pager<ReportCache> pager){
		
		return pager;
	}
	
}

